Clover coverage report - Enterprise Web Services - 1.0
Coverage timestamp: Mon May 30 2005 17:10:32 CEST
file stats: LOC: 231   Methods: 14
NCLOC: 109   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AxisWSDLContext.java 75% 75% 50% 70.5%
coverage coverage
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  *
 5   
  * Copyright (c) 2001-2004 The Apache Software Foundation.  All rights
 6   
  * reserved.
 7   
  *
 8   
  * Redistribution and use in source and binary forms, with or without
 9   
  * modification, are permitted provided that the following conditions
 10   
  * are met:
 11   
  *
 12   
  * 1. Redistributions of source code must retain the above copyright
 13   
  *    notice, this list of conditions and the following disclaimer.
 14   
  *
 15   
  * 2. Redistributions in binary form must reproduce the above copyright
 16   
  *    notice, this list of conditions and the following disclaimer in
 17   
  *    the documentation and/or other materials provided with the
 18   
  *    distribution.
 19   
  *
 20   
  * 3. The end-user documentation included with the redistribution,
 21   
  *    if any, must include the following acknowledgment:
 22   
  *       "This product includes software developed by the
 23   
  *        Apache Software Foundation (http://www.apache.org/)."
 24   
  *    Alternately, this acknowledgment may appear in the software itself,
 25   
  *    if and wherever such third-party acknowledgments normally appear.
 26   
  *
 27   
  * 4. The names "Axis" and "Apache Software Foundation" must
 28   
  *    not be used to endorse or promote products derived from this
 29   
  *    software without prior written permission. For written
 30   
  *    permission, please contact apache@apache.org.
 31   
  *
 32   
  * 5. Products derived from this software may not be called "Apache",
 33   
  *    nor may "Apache" appear in their name, without prior written
 34   
  *    permission of the Apache Software Foundation.
 35   
  *
 36   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 37   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 38   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 39   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 40   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 41   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 42   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 43   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 44   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 45   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 46   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 47   
  * SUCH DAMAGE.
 48   
  * ====================================================================
 49   
  *
 50   
  * This software consists of voluntary contributions made by many
 51   
  * individuals on behalf of the Apache Software Foundation.  For more
 52   
  * information on the Apache Software Foundation, please see
 53   
  * <http://www.apache.org/>.
 54   
  */
 55   
 
 56   
 package org.apache.geronimo.ews.ws4j2ee.context.wsdl.impl;
 57   
 
 58   
 import org.apache.axis.wsdl.symbolTable.BindingEntry;
 59   
 import org.apache.axis.wsdl.symbolTable.Element;
 60   
 import org.apache.axis.wsdl.symbolTable.PortEntry;
 61   
 import org.apache.axis.wsdl.symbolTable.PortTypeEntry;
 62   
 import org.apache.axis.wsdl.symbolTable.ServiceEntry;
 63   
 import org.apache.axis.wsdl.symbolTable.SymTabEntry;
 64   
 import org.apache.axis.wsdl.symbolTable.SymbolTable;
 65   
 import org.apache.axis.wsdl.symbolTable.TypeEntry;
 66   
 import org.apache.commons.logging.Log;
 67   
 import org.apache.commons.logging.LogFactory;
 68   
 import org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext;
 69   
 import org.apache.geronimo.ews.ws4j2ee.context.wsdl.type.SchemaType;
 70   
 
 71   
 import javax.wsdl.Binding;
 72   
 import javax.wsdl.PortType;
 73   
 import javax.wsdl.Service;
 74   
 import javax.xml.namespace.QName;
 75   
 import java.util.Collection;
 76   
 import java.util.HashMap;
 77   
 import java.util.Iterator;
 78   
 import java.util.Map;
 79   
 import java.util.Vector;
 80   
 
 81   
 /**
 82   
  * <p>This Class is a wrapper fo the Axis SymbolTable. Since SymbolTable is parsed
 83   
  * completly it is not editable so the methods will throw the
 84   
  * UnsupportedOperationException.</p>
 85   
  *
 86   
  * @author Srinath Perera(hemapani@opensource.lk)
 87   
  * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext
 88   
  */
 89   
 public class AxisWSDLContext extends AbstractWSDLContext implements WSDLContext {
 90   
     protected static Log log =
 91   
             LogFactory.getLog(AxisWSDLContext.class.getName());
 92   
     private SymbolTable symbolTable;
 93   
     private HashMap services;
 94   
     private HashMap bindings;
 95   
     private HashMap portetypes;
 96   
     private HashMap ports;
 97   
 
 98   
     private boolean verbose = false;
 99   
 
 100  18
     public AxisWSDLContext(SymbolTable axisSymbltable) {
 101  18
         this.symbolTable = axisSymbltable;
 102  18
         this.services = new HashMap();
 103  18
         this.bindings = new HashMap();
 104  18
         this.portetypes = new HashMap();
 105  18
         this.ports = new HashMap();
 106  18
         Iterator it = symbolTable.getHashMap().values().iterator();
 107  18
         while (it.hasNext()) {
 108  299
             Vector v = (Vector) it.next();
 109  299
             for (int i = 0; i < v.size(); ++i) {
 110  299
                 SymTabEntry entry = (SymTabEntry) v.elementAt(i);
 111  299
                 if (entry instanceof ServiceEntry) {
 112  18
                     Service service = ((ServiceEntry) entry).getService();
 113  18
                     this.services.put(service.getQName(), entry);
 114  281
                 } else if (entry instanceof BindingEntry) {
 115  18
                     Binding binding = ((BindingEntry) entry).getBinding();
 116  18
                     this.bindings.put(binding.getQName(), entry);
 117  263
                 } else if (entry instanceof PortTypeEntry) {
 118  18
                     PortType portType = ((PortTypeEntry) entry).getPortType();
 119  18
                     this.portetypes.put(portType.getQName(), entry);
 120  245
                 } else if (entry instanceof PortEntry) {
 121  18
                     PortEntry port = ((PortEntry) entry);
 122  18
                     this.ports.put(port.getQName().getLocalPart(), entry);
 123   
                 }
 124   
             }
 125   
         }
 126   
     }
 127   
 
 128   
     /**
 129   
      * Symbol table can't be edited
 130   
      */
 131  0
     public void addService(Service service) {
 132  0
         throw new UnsupportedOperationException("Symboltable can't be edited");
 133   
     }
 134   
 
 135   
     /**
 136   
      * Symbol table can't be edited
 137   
      */
 138  0
     public void addType(SchemaType type) {
 139  0
         throw new UnsupportedOperationException("Symboltable can't be edited");
 140   
     }
 141   
 
 142   
     /**
 143   
      * 
 144   
      */
 145  14
     public BindingEntry getBinding(QName bindingname) {
 146  14
         if (bindingname == null) {
 147   
             //if binding not specified the first one will return
 148  0
             Iterator values = this.bindings.values().iterator();
 149  0
             if (values.hasNext())
 150  0
                 return (BindingEntry) values.next();
 151   
         }
 152  14
         return (BindingEntry) this.bindings.get(bindingname);
 153   
     }
 154   
 
 155   
     /* (non-Javadoc)
 156   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getBindings()
 157   
      */
 158  0
     public Collection getBindings() {
 159  0
         return this.bindings.values();
 160   
     }
 161   
 
 162   
     /* (non-Javadoc)
 163   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getPortType(org.apache.xml.utils.QName)
 164   
      */
 165  13
     public PortTypeEntry getPortType(QName portname) {
 166  13
         return (PortTypeEntry) this.portetypes.get(portname);
 167   
     }
 168   
 
 169   
     /* (non-Javadoc)
 170   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getPortTypes()
 171   
      */
 172  0
     public Collection getPortTypes() {
 173  0
         return this.portetypes.values();
 174   
     }
 175   
 
 176   
     /* (non-Javadoc)
 177   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getService(org.apache.xml.utils.QName)
 178   
      */
 179  2
     public ServiceEntry getService(QName servicename) {
 180  2
         return (ServiceEntry) this.services.get(servicename);
 181   
     }
 182   
 
 183   
     /* (non-Javadoc)
 184   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getServices()
 185   
      */
 186  11
     public Collection getServices() {
 187  11
         return this.services.values();
 188   
     }
 189   
 
 190   
     /* (non-Javadoc)
 191   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getType(org.apache.xml.utils.QName)
 192   
      */
 193  0
     public TypeEntry getType(QName typename) {
 194   
         // TODO Auto-generated method stub
 195  0
         return symbolTable.getType(typename);
 196   
     }
 197   
 
 198   
     /* (non-Javadoc)
 199   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getTypes()
 200   
      */
 201  0
     public Map getTypes() {
 202  0
         return symbolTable.getTypeIndex();
 203   
     }
 204   
 
 205   
     /* (non-Javadoc)
 206   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getElement(javax.xml.namespace.QName)
 207   
      */
 208  0
     public Element getElement(QName name) {
 209  0
         return this.symbolTable.getElement(name);
 210   
     }
 211   
 
 212   
     /* (non-Javadoc)
 213   
      * @see org.apache.geronimo.ews.ws4j2ee.context.wsdl.WSDLContext#getPort()
 214   
      */
 215  14
     public PortEntry getPort(QName name) {
 216  14
         if (verbose)
 217  0
             log.info("getting port type " + name);
 218  14
         Object obj = this.ports.get(name);
 219   
         //when Symbol table populates the URI of the port is given as ""
 220   
         //so we have to cheat 
 221  14
         if (obj == null) {
 222  14
             obj = this.ports.get(name.getLocalPart());
 223   
         }
 224  14
         return (PortEntry) obj;
 225   
     }
 226   
 
 227  1
     public String getTargetNSURI() {
 228  1
         return symbolTable.getDefinition().getTargetNamespace();
 229   
     }
 230   
 }
 231